//
//  RootViewController.m
//  TFView
//
//  Created by lanou3g on 15/6/13.
//  Copyright (c) 2015年 多飞科技. All rights reserved.
//

#import "RootViewController.h"
#import "LoginView.h"
#import "TFView.h"
#import "FindView.h"
#import "RegniserView.h"
@interface RootViewController ()

@end

@implementation RootViewController





- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dotap:)];
    [self.view addGestureRecognizer:tapGR];
    [tapGR release];
    
    NSString *name = @"zhangsan ";
    NSLog(@"name = %@",name);
    if (name) {
     name = @"lisi";
        NSLog(@"%@",name);
    }else{
        
        NSLog(@"sssss");
    }
    
    
    
//    UIImageView *image = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
//    [image ]
//    
    
    
    
    
    LoginView*loginView = [[LoginView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    [self.view addSubview:loginView];
    loginView.userNameLTView.ltTextField.delegate = self;
    loginView.passWordLTView.ltTextField.delegate = self;
    loginView.tag = 101;
    [loginView release];
    
//     LoginView *loginView = (LoginView *)self.view;
    
    
//    给登录按钮添加方法
    [loginView.loginButton addTarget:self action:@selector(loginButton:) forControlEvents: UIControlEventTouchUpInside];
    
    
    
//    给注册按钮添加方法
    
    [loginView.regniserButton addTarget:self action:@selector(regniserButton:) forControlEvents: UIControlEventTouchUpInside];
    
//    给找回密码按钮添加方法
    [loginView.findButton addTarget:self action:@selector(findButton:) forControlEvents: UIControlEventTouchUpInside];
    

    
    
    
    
    
    
}


-(void)dotap:(id)sender{
    [self.view endEditing:YES];

}




//实现登录按钮方法：
-(void)loginButton:(UIButton*)button{
    NSLog(@"我登陆了");
    LoginView*lgView = (LoginView*)[self.view viewWithTag:101];
    if ([lgView.userNameLTView.ltTextField.text isEqual:@"finding"]&&[lgView.passWordLTView.ltTextField.text isEqual:@"123"]) {
        UIAlertView*alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"欢迎回来，finding大师~" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
        [alertView show];
        [alertView release];
    }else{
        UIAlertView*alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"密码不正确，finding大师~" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
        [alertView show];
        [alertView release];
        
    }
    
}


//实现注册按钮方法：
-(void)regniserButton:(UIButton*)button{
    NSLog(@"我注册了");
    RegniserView*regniserView = [[RegniserView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    [self.view addSubview:regniserView];
    regniserView.backgroundColor = [UIColor yellowColor];
    [regniserView bringSubviewToFront:regniserView];
    
    
}

//实现找回密码按钮发方法：
-(void)findButton:(UIButton*)button{
    NSLog(@"我找到了密码");
    FindView*findPassView = [[FindView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    findPassView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:findPassView];
    [self.view bringSubviewToFront:findPassView];
    [findPassView release];
}



-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    LoginView*loginView = (LoginView*)[self.view viewWithTag:101];
    if (loginView.userNameLTView.ltTextField==textField) {
        [loginView.passWordLTView.ltTextField becomeFirstResponder];
        
        [loginView.userNameLTView.ltTextField resignFirstResponder];
    }else{
        [loginView.passWordLTView.ltTextField resignFirstResponder];
    }
    
    return YES;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
